Dynomotion

Group: DynoMotion Message: 10488 From: Dan Date: 11/11/2014
Subject: A few questions
Attachments :
    Tom,
    I got a couple quick questions
     
    1. Is there a way to check if a thread/program is running from within another C program? Example, if I have a programming running as thread 1, and I want to check to see if thread 2 is currently active?
     
    2. Is there a way to watch for activation of a KmotionCNC user button from within a C programming running on the KFLOP? Some of my user button functions I want to be toggled, so right now I have to use two buttons for 1 function (one to set a bit and one to clear a bit)
     
    3. What are the “key” values to the left of the user button descriptions on the setup screen. Like the number 120, 121, 122, 123 in the attached picture?
    user buttons
     
     
    Thanks,
    Dan
     
    Group: DynoMotion Message: 10494 From: Tom Kerekes Date: 11/11/2014
    Subject: Re: A few questions
    Hi Dan,

    Again you hijacked someone Else's Thread.  Please start a new Conversation for your own new topic.

    Regarding:

    #1  There is an undocumented variable:

    extern volatile int ThreadActive;  // one bit for each thread   

    That can be used to check which Threads are Active.  Bit zero is the KFLOP System Thread and should always be active.  Another (probably better approach) might be to set status (ie Virtual Bits) yourself for when tasks begin and end.  There may be some race conditions associated with using this status. For example you might test and determine a Thread is running, but then it might terminate before you can tell it to do something.

    #2 You can certainly assign a C Program to a button to toggle a bit:

    if (ReadBit(46))
        ClearBit(46);
    else
        SetBit(46);

    But you won't be able to tell the state from the User Button.

    #3 Did you push the "Help" button on the screen and read the description?

    Regards
    TK


    From: "'Dan' engnerdan@... [DynoMotion]" <DynoMotion@yahoogroups.com>
    To: DynoMotion@yahoogroups.com
    Sent: Tuesday, November 11, 2014 8:15 AM
    Subject: [DynoMotion] A few questions

     
    Tom,
    I got a couple quick questions
     
    1. Is there a way to check if a thread/program is running from within another C program? Example, if I have a programming running as thread 1, and I want to check to see if thread 2 is currently active?
     
    2. Is there a way to watch for activation of a KmotionCNC user button from within a C programming running on the KFLOP? Some of my user button functions I want to be toggled, so right now I have to use two buttons for 1 function (one to set a bit and one to clear a bit)
     
    3. What are the “key” values to the left of the user button descriptions on the setup screen. Like the number 120, 121, 122, 123 in the attached picture?
    user buttons
     
     
    Thanks,
    Dan
     


    Group: DynoMotion Message: 10500 From: Dan Date: 11/11/2014
    Subject: Re: A few questions [1 Attachment]
    Attachments :
      Tom,
      Sorry I am not sure how I hijacked someone else's thread.
      1. ThreadActive sounds like it will work, I am just looking to restart a thread if it gets stopped by an E-stop.
       
      2. I want to know if I can watch a variable to monitor for button presses. Like “UserButtonVariable” in this made up bit of code.
       
      if (UserButtonVariable==3) //User button 3 pressed
          {
         if (ReadBit(46))
              ClearBit(46);
          }
          else
              SetBit(46);
       
      3. Yes I have been to the help section frequently, but I missed the section on the user buttons.
       
      Thanks,
      Dan
       
      Sent: Tuesday, November 11, 2014 3:22 PM
      Subject: Re: [DynoMotion] A few questions [1 Attachment]
       
       

      Hi Dan,

      Again you hijacked someone Else's Thread.  Please start a new Conversation for your own new topic.

      Regarding:

      #1  There is an undocumented variable:

      extern volatile int ThreadActive;  // one bit for each thread   

      That can be used to check which Threads are Active.  Bit zero is the KFLOP System Thread and should always be active.  Another (probably better approach) might be to set status (ie Virtual Bits) yourself for when tasks begin and end.  There may be some race conditions associated with using this status. For example you might test and determine a Thread is running, but then it might terminate before you can tell it to do something.

      #2 You can certainly assign a C Program to a button to toggle a bit:

      if (ReadBit(46))
          ClearBit(46);
      else
          SetBit(46);

      But you won't be able to tell the state from the User Button.

      #3 Did you push the "Help" button on the screen and read the description?

      Regards
      TK
       
      Group: DynoMotion Message: 10501 From: Tom Kerekes Date: 11/11/2014
      Subject: Re: A few questions
      Hi Dan,

      Regarding #2:

      You might configure the button to set a Virtual bit (such as bit 48).  Then the C program could test Virtual the bit, when it sees it set, toggle something and then clear the Virtual bit.

      if (ReadBit(48))
      {
          ClearBit(48);

          if (ReadBit(46))
              ClearBit(46);
          else
              SetBit(46);
      }


      Regards
      TK


      From: "'Dan' engnerdan@... [DynoMotion]" <DynoMotion@yahoogroups.com>
      To: DynoMotion@yahoogroups.com
      Sent: Tuesday, November 11, 2014 3:23 PM
      Subject: Re: [DynoMotion] A few questions

       
      Tom,
      Sorry I am not sure how I hijacked someone else's thread.
      1. ThreadActive sounds like it will work, I am just looking to restart a thread if it gets stopped by an E-stop.
       
      2. I want to know if I can watch a variable to monitor for button presses. Like “UserButtonVariable” in this made up bit of code.
       
      if (UserButtonVariable==3) //User button 3 pressed
          {
         if (ReadBit(46))
              ClearBit(46);
          }
          else
              SetBit(46);
       
      3. Yes I have been to the help section frequently, but I missed the section on the user buttons.
       
      Thanks,
      Dan
       
      Sent: Tuesday, November 11, 2014 3:22 PM
      Subject: Re: [DynoMotion] A few questions [1 Attachment]
       
       
      Hi Dan,

      Again you hijacked someone Else's Thread.  Please start a new Conversation for your own new topic.

      Regarding:

      #1  There is an undocumented variable:

      extern volatile int ThreadActive;  // one bit for each thread   

      That can be used to check which Threads are Active.  Bit zero is the KFLOP System Thread and should always be active.  Another (probably better approach) might be to set status (ie Virtual Bits) yourself for when tasks begin and end.  There may be some race conditions associated with using this status. For example you might test and determine a Thread is running, but then it might terminate before you can tell it to do something.

      #2 You can certainly assign a C Program to a button to toggle a bit:

      if (ReadBit(46))
          ClearBit(46);
      else
          SetBit(46);

      But you won't be able to tell the state from the User Button.

      #3 Did you push the "Help" button on the screen and read the description?

      Regards
      TK
       

      From: "'Dan' engnerdan@... [DynoMotion]" <DynoMotion@yahoogroups.com>
      To: DynoMotion@yahoogroups.com
      Sent: Tuesday, November 11, 2014 8:15 AM
      Subject: [DynoMotion] A few questions
       
       
      Tom,
      I got a couple quick questions
       
      1. Is there a way to check if a thread/program is running from within another C program? Example, if I have a programming running as thread 1, and I want to check to see if thread 2 is currently active?
       
      2. Is there a way to watch for activation of a KmotionCNC user button from within a C programming running on the KFLOP? Some of my user button functions I want to be toggled, so right now I have to use two buttons for 1 function (one to set a bit and one to clear a bit)
       
      3. What are the “key” values to the left of the user button descriptions on the setup screen. Like the number 120, 121, 122, 123 in the attached picture?
      user buttons
       
       
      Thanks,
      Dan